/**
 * Created by DevilsEyes on 2016/3/14.
 */
'use strict';

define(['text!path/category/tmp.html'], function (page) {

    var render = template.compile(page);

    var apiList = {
        getCategory: api + 'categorypage'
    };

    var vm = new Page.creat({
        $id: 'category',
        $model: {
            data: {},
            $: {},
            ratio: 1,
            init: function () {

                //$.ajax({
                //    url: '../testData/homepage.json',
                ex.jsonp({
                    url: apiList.getCategory,
                    success: function (obj) {
                        if (!vm.isThisPage())return;
                        console.log(obj);

                        vm.data = {
                            list: obj.data || []
                        };

                        $('#page').html(render(vm.data));

                        ex.async(function () {

                            $('.item div').each(function () {
                                var $this = $(this);
                                $this.height($this.width());
                            });

                            vm.bindEvent(vm.event);
                            vm.bind$(vm.$);

                        });

                    }
                })
            },
            event: {}
        }
    });

    return {
        init: function () {
            vm.$init({
                setTitle: '商品分类',
                id: 'category'
            });
            vm.init();
        }
    }
});